package com.ydt.dockingclients.controller;

import cn.hutool.http.server.HttpServerRequest;
import com.alibaba.fastjson2.JSON;
import com.ydt.dockingclients.request.SdkYdtOrderCreateNoticeRequest;
import com.ydt.dockingclients.request.SdkYdtOrderRefundNoticeRequest;
import com.ydt.dockingclients.response.YdtNoticeResponseHandel;
import com.ydt.dockingclients.utils.HttpServletRequestReader;
import com.ydt.dockingclients.utils.YdtSdkResult;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@Slf4j
@RestController
@RequestMapping("/api/ytd/v1.8/order/notice")
public class NoticeOrderController {
    /**
     * 订单创建回告（接收运达通通知接口）
     *
     * @param request
     * @return
     */
    @PostMapping("/create/notice")
    public YdtSdkResult createNotice(HttpServletRequest request) {
        SdkYdtOrderCreateNoticeRequest noticeRequest = YdtNoticeResponseHandel.createNotice(request);
        log.info("运达通创建订单回告：{}", noticeRequest);
        /**
         * 业务处理
         */
        return YdtSdkResult.success();
    }

    /**
     * 订单退款回告通知（接收运达通通知接口）
     *
     * @param request
     * @return
     */
    @PostMapping("/refund/notice")
    public YdtSdkResult refundNotice(HttpServletRequest request) {
        SdkYdtOrderRefundNoticeRequest noticeRequest = YdtNoticeResponseHandel.refundNotice(request);
        /**
         * 业务处理
         */
        return YdtSdkResult.success();
    }
}
